package com.windward.vii.dao.mapper;

import com.windward.vii.dao.entity.AssetPlatformProfitRate;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface AssetPlatformProfitRateMapper {
    @Delete({
        "delete from asset_platform_profit_rate",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into asset_platform_profit_rate (id, rate, ",
        "type, status, create_time)",
        "values (#{id,jdbcType=BIGINT}, #{rate,jdbcType=DECIMAL}, ",
        "#{type,jdbcType=TINYINT}, #{status,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP})"
    })
    int insert(AssetPlatformProfitRate record);

    int insertSelective(AssetPlatformProfitRate record);

    @Select({
        "select",
        "id, rate, type, status, create_time",
        "from asset_platform_profit_rate",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    AssetPlatformProfitRate selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(AssetPlatformProfitRate record);

    @Update({
        "update asset_platform_profit_rate",
        "set rate = #{rate,jdbcType=DECIMAL},",
          "type = #{type,jdbcType=TINYINT},",
          "status = #{status,jdbcType=TINYINT},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(AssetPlatformProfitRate record);

    @Select({
            "select",
            "id, rate, type, status, create_time",
            "from asset_platform_profit_rate",
            "where type = #{id,jdbcType=TINYINT} and status = 1 limit 1"
    })
    @ResultMap("BaseResultMap")
    AssetPlatformProfitRate selectByType(Integer type);
}